package com.quick.controller;
import com.quick.base.KeyValue;
import com.quick.base.Page;
import com.quick.base.QueryParam;
import com.quick.base.Search;
import com.quick.service.ISysUserService;
import com.quick.sys.domain.dto.SysUserDTO;
import com.quick.sys.domain.dto.SysUserLoginDTO;
import com.quick.sys.domain.pojo.SysUser;
import com.quick.sys.domain.vo.SysUserDetailVo;
import com.quick.sys.domain.vo.SysUserVo;
import com.quick.sys.domain.vo.UserLoginVo;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
@RestController
@RequestMapping("api/sys/user")
@Api(tags = "用户管理")
public class SysUserController {

    @Autowired
    private ISysUserService userService;
    @ApiOperation(value = "用户分页查询列表", notes = "用户分页查询列表")
    @PostMapping("search")
    public Page<SysUserVo> search(@RequestBody Search<SysUser> search) {
        return userService.search(search);
    }
    
    @ApiOperation(value = "查询全部用户", notes = "查询全部用户")
    @PostMapping("loadSysUserAll")
    public List<KeyValue> loadSysUserAll(@RequestBody QueryParam search) {
        return userService.loadSysUserAll(search);
    }
    @GetMapping("getUserInfo")
    @ApiOperation("获取用户信息")
    public SysUserDetailVo getUserInfo(){
        return userService.getUser();
    }
    @ApiOperation(value = "用户新增", notes = "用户新增")
    @PostMapping("add")
    public Boolean addUser(@RequestBody SysUserDTO user) {
		return userService.saveUser(user);
    }
    
    @ApiOperation(value = "用户删除", notes = "用户删除")
    @GetMapping("del/{id}")
    public Boolean delUser(@PathVariable("id") Long id) {
		return userService.delUser(id);
    }

    @ApiOperation("用户登录")
    @PostMapping("login")
    public UserLoginVo login(@RequestBody SysUserLoginDTO login){
        return userService.userLogin(login);
    }

    @ApiOperation("用户注销/登出")
    @PostMapping("loginOut")
    public Boolean loginOut(){
        return  userService.loginOut();
    }


}
